package Hot100.Medium.String_2Pointer.DoublePointer;

public class LC11_MaxVolumeOfWater {
    public static void main(String[] args) {

    }

    public int maxArea(int[] height) {
        int len = height.length;
        if(len == 0) return 0;
        int l = 0, r = len - 1;
        int res = 0;
        while(l < r){
            int distance = r - l;
            res = Math.max(Math.min(height[l], height[r]) * distance, res);
            // 移动较小的边
            if(height[l] < height[r]){
                l++;
            } else {
                r--;
            }
        }
        return res;
    }
}
